const Mock=require('mockjs');
//获取 mock.Random 对象
const Random = Mock.Random;
// mock一组数据
const allTitle=[
    "关于深化增值税改革有关政策的公告",'关于深化增值税改革有关事项的公告','关于调整增值税纳税申报有关事项的公告','关于实施小微企业普惠性税收减免政策的通知','这是测试数据','555555','99999'
]
const allKey=[
    "政策",'增值税','税纳','税收减免','这是测试数据','555555','测试'
]

// 获取用户列表
const dataUser = 
    {
        "id": 28,
        "username": "tige1200",
        "mobile": "test",
        "type": 1,
        "openid": "",
        "email": "test@test.com",
        "create_time": "2017-11-10T03:47:13.533Z",
        "modify_time": null,
        "is_delete": false,
        "is_active": false
    }



const meta = {
    "msg": "用户创建成功",
    "status": 201
}

const addUser = function(){
    const user = []
    user.push(dataUser)
    user.push(meta)
    return addUser
}
// 删除用户
const datas = {
    data: ""
}

const metas ={
    "msg": '删除成功',
    "status": '200'
}

const userId = function(){
    const userid = []
    userid.push(datas)
    userid.push(metas)
    return userid
}

const produceNewDate=function(){
    let articles=[];
   
        let newArticleObject={
            id: 500,
            rid: 0,
            username: "admin",
            password: 'lxf',
            mobile: "123",
            email: "123@qq.com",
            token: "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjUwMCwicmlkIjowLCJpYXQiOjE1MTI1NDQyOTksImV4cCI6MTUxMjYzMDY5OX0.eGrsrvwHm-tPsO9r_pxHIQ5i5L1kX9RX444uwnRGaIM"
        
        }
       let meta= {
            msg : "登录成功",
            code : 200
        }
        articles.push(meta)
        articles.push(newArticleObject);
    return{
        articles:articles
    }
}

const keysData=function(){
    let articles=[];
    for(let i=0;i<7;i++){
        articles.push(allKey[i]);
    }
    return{
        articles:articles
    }
}
// 需要几个接口就定义几个function,
//Mock.mock(url(接口地址),method(接口方式),上面定义的数据);
Mock.mock('/searchKey','post',keysData)
Mock.mock('/login','post',produceNewDate);
Mock.mock('/users','post',addUser)
Mock.mock('/users/userId=1','delete',userId)